<template>
	<view>
		<view class="">
			测试接口
		</view>
		<image style="width: 340rpx;height: 90rpx;" :src="codeImg" mode=""></image>
		<u-field v-model="username" label="用户名" placeholder="请填写用户名">
		</u-field>
		<u-field v-model="password" label="密码" placeholder="请填写密码">
		</u-field>
		<u-field v-model="captcha" label="验证码" placeholder="请填写验证码">
		</u-field>
		<u-button @click="login" type="primary">登录</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				codeImg: "",
				"captcha": "",
				"checkKey": "",
				"password": "",
				"username": "",
				timestamp:0
			}
		},
		onShow() {
			this.getCode()
		},
		methods: {
			getCode() {
				this.timestamp = new Date().getTime()
				this.$request.get(this.$api.randomImage + this.timestamp).then(res => {
					this.codeImg = res.result
				})
			},
			login() {
				this.$request.post(this.$api.mLogin,{
					"captcha": this.captcha,
					"checkKey": this.timestamp,
					"password": this.password,
					"username": this.username
				}).then(res => {

				})

			}
		}
	}
</script>

<style>

</style>
